package humanMirror.model.questionLibrary;

/**
 * This class is used for storing an information about organ.
 * @author Vladimir Vyshko
 * @author Anton Samarsky
 * @author Dima Glushko
 * @version 1.04 21 jun 2012
 */
public class OrganInfo {

    private int organParameters[][];
    
    public OrganInfo(){  
        
        organParameters = new int[SomeConstants.COUNT_OF_ORGANS][SomeConstants.COUNT_OF_PARAMS];
        
    }
    
    /**
     * This method checks the correctness of the arguments.
     * @param organ is id of organ.
     * @param param is id of parameter of organ organ.
     * @return "true" if any of arguments is wrong.
     */
    public boolean wrongArguments(int organ, int param) {
    	if (organ >= SomeConstants.COUNT_OF_ORGANS || organ < 0)
    		return true;
    	if (param >= SomeConstants.COUNT_OF_PARAMS || param < 0)
    		return true;
    	return false; //all is OK
    }
    
    /**
     * This method is used for setting some parameter of organ.
     * @param organ is id of organ.
     * @param param is id of parameter of organ organ.
     * @param value is value of effect which you want to set.
     * @throws IllegalArgumentException if it was specified nonexistent organ or parameter.
     */
    public void setParameter(int organ, int param, int value){
        
        if (this.wrongArguments(organ,param)) 
            throw new IllegalArgumentException("It was specified wrong organ or parameter!");
        
        organParameters[organ][param] = value;
        
    }
    
    /**
     * This method is used for getting some parameter of organ.
     * @param organ is id of organ.
     * @param param is id of parameter of organ organ.
     * @throws IllegalArgumentException if it was specified nonexistent organ or parameter.
     * @return value of effect.
     */
     public int getParameter(int organ, int param){
        
    	if (this.wrongArguments(organ,param))
    		throw new IllegalArgumentException("It was specified wrong organ or parameter!");
        
        return organParameters[organ][param];
        
    }
    
     /**
      * This method is used to add each element of object values to each element of current object
      * @param values object whose elements are added to current object
      */
     public void addParameters(OrganInfo values){
    	 for (int currentOrgan = 0; currentOrgan < SomeConstants.COUNT_OF_ORGANS; currentOrgan++)
    		 for (int currentParam = 0; currentParam < SomeConstants.COUNT_OF_PARAMS; currentParam++)
    			 organParameters[currentOrgan][currentParam] += values.getParameter(currentOrgan, currentParam);
     }
  
}
